package com.springapi.service.impl;

import com.springapi.entity.Mailreport;
import com.springapi.dao.MailreportDao;
import com.springapi.service.MailreportService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统设置(Mailreport)表服务实现类
 *
 * @author makejava
 * @since 2025-01-23 11:18:13
 */
@Service("mailreportService")
public class MailreportServiceImpl implements MailreportService {
    @Resource
    private MailreportDao mailreportDao;

    @Override
    public List<Mailreport> findmailreport1(int appid, int shopid) {
        return mailreportDao.findmailreport1(appid,shopid);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Mailreport queryById(Integer id) {
        return this.mailreportDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param mailreport 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<Mailreport> queryByPage(Mailreport mailreport, PageRequest pageRequest) {
        long total = this.mailreportDao.count(mailreport);
        return new PageImpl<>(this.mailreportDao.queryAllByLimit(mailreport, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param mailreport 实例对象
     * @return 实例对象
     */
    @Override
    public Mailreport insert(Mailreport mailreport) {
        this.mailreportDao.insert(mailreport);
        return mailreport;
    }

    /**
     * 修改数据
     *
     * @param mailreport 实例对象
     * @return 实例对象
     */
    @Override
    public Mailreport update(Mailreport mailreport) {
        this.mailreportDao.update(mailreport);
        return this.queryById(mailreport.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.mailreportDao.deleteById(id) > 0;
    }
}
